﻿/*
 * Created by SharpDevelop.
 * User: Kevin
 * Date: 2017/5/13
 * Time: 16:31
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;
using System.Net;
using System.Web;

namespace RestTest
{
	/// <summary>
	/// Description of HttpUtils.
	/// </summary>
	public class HttpUtils
	{
		public HttpUtils()
		{
		}
        public static HttpWebRequest buildHeader(String path, String method)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path);
	        request.Method = method;
            return request;
        }

        public static string Http_state(HttpWebRequest request)
        {
        	string rtn=null;
            try
            {
                using (WebResponse response = request.GetResponse())
                {
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            		{
                        //if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK) { }
                		rtn = reader.ReadToEnd();
            		}
                }
            }
            catch (WebException ex)
            {
                rtn = ex.ToString();
            }
            return rtn;
        }

	}
}
